﻿using AutoMapper;
using Comm100.Application.Services;
using Comm100.Framework.Auditing;
using Comm100.Framework.Authorization;
using Comm100.Public.Audit;
using Bot.Application.Dto;
using Bot.Application.Services;
using Bot.Domain.Bo;
using Bot.Domain.Entities;
using Bot.Domain.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;
using Bot.Domain;

namespace Bot.Application.AnswerInChannelLocationRequests.Service
{
    public class AnswerInChannelLocationRequestAppService : BaseAppService, IAnswerInChannelLocationRequestAppService
    {
        private IAnswerInChannelLocationRequestDomainService _domainService;

        public AnswerInChannelLocationRequestAppService(IAnswerInChannelLocationRequestDomainService domainService) : base()
        {
            this._domainService = domainService;
        }

        [Authorization(BotPermission.MANAGE_BOTS)]
        //[Audit(BotEntity.ANSWERINCHANNELLOCATIONREQUEST, AuditAction.DESTROY)]
        public void Delete(Guid id)
        {
            _domainService.Delete(id);
        }

        [Authorization(BotPermission.MANAGE_BOTS)]
        //[Audit(BotEntity.ANSWERINCHANNELLOCATIONREQUEST, AuditAction.CREATE)]
        public AnswerInChannelLocationRequestDto Add(Guid answerInChannelId, AnswerInChannelLocationRequestCreateDto dto)
        {
            AnswerInChannelLocationRequest answerInChannelLocationRequest = _domainService.CreateWithAnswerInChannelId(answerInChannelId, Mapper.Map<AnswerInChannelLocationRequest>(dto));
            return Mapper.Map<AnswerInChannelLocationRequestDto>(answerInChannelLocationRequest);
        }

        [Authorization(BotPermission.MANAGE_BOTS)]
        //[Audit(BotEntity.ANSWERINCHANNELLOCATIONREQUEST, AuditAction.UPDATE)]
        public AnswerInChannelLocationRequestDto Update(AnswerInChannelLocationRequestUpdateDto dto)
        {
            AnswerInChannelLocationRequest answerInChannelLocationRequest = _domainService.Update(Mapper.Map<AnswerInChannelLocationRequestUpdateBo>(dto));
            return Mapper.Map<AnswerInChannelLocationRequestDto>(answerInChannelLocationRequest);
        }

        public AnswerInChannelLocationRequestDto Get(Guid id)
        {
            AnswerInChannelLocationRequest answerInChannelLocationRequest = _domainService.Get(id);
            return Mapper.Map<AnswerInChannelLocationRequestDto>(answerInChannelLocationRequest);
        }
        public AnswerInChannelLocationRequestDto GetByAnswerInChannelId(Guid answerInChannelId)
        {
            AnswerInChannelLocationRequest answerInChannelLocationRequest = _domainService.GetByAnswerInChannelId(answerInChannelId);
            return Mapper.Map<AnswerInChannelLocationRequestDto>(answerInChannelLocationRequest);
        }

        public IEnumerable<AnswerInChannelLocationRequestDto> GetList()
        {
            IEnumerable<AnswerInChannelLocationRequest> list = _domainService.List();
            return Mapper.Map<IEnumerable<AnswerInChannelLocationRequestDto>>(list);
        }
    }
}
